<template>
  <a-card :bordered='false'>
    <div class='content' ref='content'>
      <div class='content-left'>
        <div class='content-left-item'>
          <div class='headerBox'>报工统计-人员</div>
          <div class='content-left-item-content'>
            <work-report-person-overview ref='workReportPersonOverview'></work-report-person-overview>
          </div>
        </div>
        <div class='content-left-item'>
          <div class='headerBox'>报工统计-阶段</div>
          <div class='content-left-item-content'>
            <work-report-phase-overview ref='workReportPhaseOverview'></work-report-phase-overview>
          </div>
        </div>


      </div>
    </div>
  </a-card>
</template>

<script>
import { randomUUID, splitByNum } from '@/utils/util'
import { getAction } from '@api/manage'
import WorkReportPersonOverview from '@views/hifar/pm/modules/WorkReportPersonOverview'
import WorkReportPhaseOverview from '@views/hifar/pm/modules/WorkReportPhaseOverview'
import HfElevatorLayer from '@/views/hifar/components/HfElevatorLayer'
import { filterDictTextByCache } from '@comp/dict/JDictSelectUtil'


export default {
  name: 'HfPmWorkReportsStatistics',
  components: { HfElevatorLayer, WorkReportPersonOverview, WorkReportPhaseOverview },
  inject: {
    getContainer: {
      default: () => document.body
    }
  },
  data() {
    return {
      title: '报工统计',
      visible: false,
      url: {
        queryById: '/pm/pmProject/queryById'
      }
    }
  },
  mounted() {

  },
  props: {
    selectedKeys: {
      type: [Array, String]
    }
  },
  watch: {
    selectedKeys: {
      immediate: true,
      handler(val) {
        if (val.length > 0) {
          this.getById(val.toString())
        }
      }
    }
  },
  methods: {
    getById(id) {
      getAction(this.url.queryById, { id }).then(res => {
        if (res.success) {

          this.showStatistic(res.result.shortName)
        }
      })
    },
    showStatistic(shortName) {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.workReportPersonOverview.loadData(shortName)
        this.$refs.workReportPhaseOverview.loadData(shortName)
      })
    },
    transformDataByDict(dictCode, key) {
      return filterDictTextByCache(dictCode, key)
    },
    elevatorChange(item) {
      let dom = document.getElementById(item.id)
      dom.scrollIntoView({ behavior: 'smooth' })
    }
  }


}
</script>

<style scoped>
@import '~@assets/less/common.less';
</style>
<style scoped lang='less'>

/deep/ .content {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;

  &-left {
    width: 95%;

    &-item {
      .headerBox {
        position: relative;
        margin-left: 20px;
        margin-top: 20px;
        font-size: 18px;
        color: black;

        &:after {
          content: "";
          width: calc(100% - 100px);
          height: 1px;
          position: absolute;
          left: 140px;
          right: 0;
          top: 50%;
          background: #409eff;
        }

        &:before {
          content: "";
          width: 5px;
          height: 100%;
          position: absolute;
          left: -15px;
          top: 0;
          background: #409eff;
        }
      }

      &-content {
        padding: 15px 0 20px 30px;

        .ant-descriptions-item-label {
          width: 200px;
          min-width: 100px;
        }
      }
    }
  }

  &-right {
    position: relative;
    width: 5%;
  }
}
</style>